// --------------------------------------------------------------------------------------------
// Version: MPL 1.1/GPL 2.0/LGPL 2.1
// 
// The contents of this file are subject to the Mozilla Public License Version
// 1.1 (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
// http://www.mozilla.org/MPL/
// 
// Software distributed under the License is distributed on an "AS IS" basis,
// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
// for the specific language governing rights and limitations under the
// License.
// 
// <remarks>
// Generated by IDLImporter from file nsIAsyncShutdown.idl
// 
// You should use these interfaces when you access the COM objects defined in the mentioned
// IDL/IDH file.
// </remarks>
// --------------------------------------------------------------------------------------------
namespace Gecko
{
	using System;
	using System.Runtime.InteropServices;
	using System.Runtime.InteropServices.ComTypes;
	using System.Runtime.CompilerServices;
	
	
	/// <summary>
    /// A blocker installed by a client to be informed during some stage of
    /// shutdown and block shutdown asynchronously until some condition is
    /// complete.
    ///
    /// If you wish to use AsyncShutdown, you will need to implement this
    /// interface (and only this interface).
    /// </summary>
	[ComImport()]
	[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
	[Guid("4ef43f29-6715-4b57-a750-2ff83695ddce")]
	public interface nsIAsyncShutdownBlocker
	{
		
		/// <summary>
        /// The *unique* name of the blocker.
        ///
        /// By convention, it should respect the following format:
        /// "MyModuleName: Doing something while it's time"
        /// e.g.
        /// "OS.File: Flushing before profile-before-change"
        ///
        /// This attribute is uploaded as part of crash reports.
        /// </summary>
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		void GetNameAttribute([MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Gecko.CustomMarshalers.AStringMarshaler")] nsAStringBase aName);
		
		/// <summary>
        /// Inform the blocker that the stage of shutdown has started.
        /// Shutdown will NOT proceed until `aBarrierClient.removeBlocker(this)`
        /// has been called.
        /// </summary>
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		void BlockShutdown([MarshalAs(UnmanagedType.Interface)] nsIAsyncShutdownClient aBarrierClient);
		
		/// <summary>
        /// The current state of the blocker.
        ///
        /// In case of crash, this is converted to JSON and attached to
        /// the crash report.
        ///
        /// This field may be used to provide JSON-style data structures.
        /// For this purpose, use
        /// - nsIPropertyBag to represent objects;
        /// - nsIVariant to represent field values (which may hold nsIPropertyBag
        /// themselves).
        /// </summary>
		[return: MarshalAs(UnmanagedType.Interface)]
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		nsIPropertyBag GetStateAttribute();
	}
	
	/// <summary>
    /// A client for a nsIAsyncShutdownBarrier.
    /// </summary>
	[ComImport()]
	[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
	[Guid("d2031049-b990-43a2-95be-59f8a3ca5954")]
	public interface nsIAsyncShutdownClient
	{
		
		/// <summary>
        /// The name of the barrier.
        /// </summary>
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		void GetNameAttribute([MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Gecko.CustomMarshalers.AStringMarshaler")] nsAStringBase aName);
		
		/// <summary>
        /// Add a blocker.
        ///
        /// After a `blocker` has been added with `addBlocker`, if it is not
        /// removed with `removeBlocker`, this will, by design, eventually
        /// CAUSE A CRASH.
        ///
        /// Calling `addBlocker` once nsIAsyncShutdownBarrier::wait() has been
        /// called on the owning barrier returns an error.
        ///
        /// @param aBlocker The blocker to add. Once
        /// nsIAsyncShutdownBarrier::wait() has been called, it will not
        /// call its `aOnReady` callback until all blockers have been
        /// removed, each  by a call to `removeBlocker`.
        /// @param aFileName The filename of the callsite, as given by `__FILE__`.
        /// @param aLineNumber The linenumber of the callsite, as given by `__LINE__`.
        /// @param aStack Information on the stack that lead to this call. Generally
        /// empty when called from C++.
        /// </summary>
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		void AddBlocker([MarshalAs(UnmanagedType.Interface)] nsIAsyncShutdownBlocker aBlocker, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Gecko.CustomMarshalers.AStringMarshaler")] nsAStringBase aFileName, int aLineNumber, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Gecko.CustomMarshalers.AStringMarshaler")] nsAStringBase aStack);
		
		/// <summary>
        /// Remove a blocker.
        ///
        /// @param aBlocker A blocker previously added to this client through
        /// `addBlocker`. Noop if the blocker has never been added or has been
        /// removed already.
        /// </summary>
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		void RemoveBlocker([MarshalAs(UnmanagedType.Interface)] nsIAsyncShutdownBlocker aBlocker);
		
		/// <summary>
        /// The JS implementation of the client.
        ///
        /// It is strongly recommended that JS clients of this API use
        /// `jsclient` instead of the `nsIAsyncShutdownClient`. See
        /// AsyncShutdown.jsm for more information on the JS version of
        /// this API.
        /// </summary>
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		Gecko.JsVal GetJsclientAttribute();
	}
	
	/// <summary>
    /// Callback invoked once all blockers of a barrier have been removed.
    /// </summary>
	[ComImport()]
	[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
	[Guid("910c9309-1da0-4dd0-8bdb-a325a38c604e")]
	public interface nsIAsyncShutdownCompletionCallback
	{
		
		/// <summary>
        /// The operation has been completed.
        /// </summary>
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		void Done();
	}
	
	/// <summary>
    /// A stage of shutdown that supports blocker registration.
    /// </summary>
	[ComImport()]
	[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
	[Guid("50fa8a86-9c91-4256-8389-17d310adec90")]
	public interface nsIAsyncShutdownBarrier
	{
		
		/// <summary>
        /// The blocker registration capability.  Most services may wish to
        /// publish this capability to let services that depend on it register
        /// blockers.
        /// </summary>
		[return: MarshalAs(UnmanagedType.Interface)]
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		nsIAsyncShutdownClient GetClientAttribute();
		
		/// <summary>
        /// The state of all the blockers of the barrier.
        ///
        /// See the documentation of `nsIAsyncShutdownBlocker` for the
        /// format.
        /// </summary>
		[return: MarshalAs(UnmanagedType.Interface)]
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		nsIPropertyBag GetStateAttribute();
		
		/// <summary>
        /// Wait for all blockers to complete.
        ///
        /// Method `aOnReady` will be called once all blockers have finished.
        /// The callback always receives NS_OK.
        /// </summary>
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		void Wait([MarshalAs(UnmanagedType.Interface)] nsIAsyncShutdownCompletionCallback aOnReady);
	}
	
	/// <summary>
    /// A service that allows registering shutdown-time dependencies.
    /// </summary>
	[ComImport()]
	[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
	[Guid("db365c78-c860-4e64-9a63-25b73f89a016")]
	public interface nsIAsyncShutdownService
	{
		
		/// <summary>
        /// Create a new barrier.
        ///
        /// By convention, the name should respect the following format:
        /// "MyModuleName: Doing something while it's time"
        /// e.g.
        /// "OS.File: Waiting for clients to flush before shutting down"
        ///
        /// This attribute is uploaded as part of crash reports.
        /// </summary>
		[return: MarshalAs(UnmanagedType.Interface)]
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		nsIAsyncShutdownBarrier MakeBarrier([MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Gecko.CustomMarshalers.AStringMarshaler")] nsAStringBase aName);
		
		/// <summary>
        /// Barrier for notification profile-before-change.
        /// </summary>
		[return: MarshalAs(UnmanagedType.Interface)]
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		nsIAsyncShutdownClient GetProfileBeforeChangeAttribute();
		
		/// <summary>
        /// Barrier for notification profile-change-teardown.
        /// </summary>
		[return: MarshalAs(UnmanagedType.Interface)]
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		nsIAsyncShutdownClient GetProfileChangeTeardownAttribute();
		
		/// <summary>
        /// Barrier for notification quit-application-granted.
        /// </summary>
		[return: MarshalAs(UnmanagedType.Interface)]
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		nsIAsyncShutdownClient GetQuitApplicationGrantedAttribute();
		
		/// <summary>
        /// Barrier for notification profile-before-change2.
        /// </summary>
		[return: MarshalAs(UnmanagedType.Interface)]
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		nsIAsyncShutdownClient GetSendTelemetryAttribute();
		
		/// <summary>
        /// Barriers for global shutdown stages in the content processes.
        /// </summary>
		[return: MarshalAs(UnmanagedType.Interface)]
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		nsIAsyncShutdownClient GetContentChildShutdownAttribute();
		
		/// <summary>
        /// Barrier for notification web-workers-shutdown.
        /// </summary>
		[return: MarshalAs(UnmanagedType.Interface)]
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		nsIAsyncShutdownClient GetWebWorkersShutdownAttribute();
		
		/// <summary>
        /// Barrier for notification xpcom-threads-shutdown.
        /// </summary>
		[return: MarshalAs(UnmanagedType.Interface)]
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		nsIAsyncShutdownClient GetXpcomThreadsShutdownAttribute();
	}
}
